using System.Linq;

namespace BizTalk.BuildGenerator.MetaData.ResourceAdapters
{
    public abstract class BaseResourceAdapter
    {
        public ApplicationResource Resource { get; set; }

        protected BaseResourceAdapter(ApplicationResource resource)
        {
            Resource = resource;
        }

        protected object FindPropertyValue(string key)
        {
            return (from property in Resource.Properties where property.Name == key select property.Value).FirstOrDefault();
        }

        /// <summary>
        /// Formats a path so it is confgurable based on build parameters
        /// </summary>
        /// <param name="path"></param>
        public static string FormatResourcePath(string path)
        {
            return PathHelper.MakeConfigurable(path);
        }
    }
}